package com.vay.de.dang.online.view;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.vay.de.dang.online.R;

public class DialogWarring extends DialogBase {

    private TextView titleTv;
    private TextView hintTv;
    private TextView bntCancel;
    private DialogCallback mCallback;

    public DialogWarring(Context context) {
        super(context);
        setContentView(R.layout.dialog_warring);
        autoWidth(0.88f);

        titleTv = findViewById(R.id.title);
        hintTv = findViewById(R.id.hint);
        bntCancel = findViewById(R.id.bnt_no);

        bntCancel.setOnClickListener(v -> {
            dismiss();
        });

        findViewById(R.id.bnt_yes).setOnClickListener(v -> {
            if (mCallback != null) mCallback.onConfirm();
            dismiss();
        });
    }

    public DialogWarring setTitleText(int restId) {
        titleTv.setText(restId);
        return this;
    }

    public DialogWarring setTitleText(String title) {
        titleTv.setText(title);
        return this;
    }

    public DialogWarring setHintText(int restId) {
        hintTv.setText(restId);
        return this;
    }

    public DialogWarring setHintText(String content) {
        hintTv.setText(content);
        return this;
    }

    public DialogWarring hideCancel() {
        bntCancel.setVisibility(View.GONE);
        return this;
    }

    public void showConfirm(DialogCallback callback) {
        mCallback = callback;
        show();
    }

}
